package com.leo;

import javafx.beans.Observable;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.*;

/**
 * @ClassName CollectionDemo
 * @Description
 * @Author wangss
 * @date 2020.06.01 21:09
 * @Version 1.0
 */
public class CollectionDemo {

    public static void main(String[] args) {

        ObservableList<Object> objects = FXCollections.observableArrayList();

        ObservableSet<Object> objects1 = FXCollections.emptyObservableSet();

        ObservableMap<Object, Object> objectObjectObservableMap = FXCollections.observableHashMap();

        SimpleStringProperty s1 = new SimpleStringProperty("a");
        SimpleStringProperty s2 = new SimpleStringProperty("b");

        ObservableList<SimpleStringProperty> list = FXCollections.observableArrayList(param -> {
            System.out.println("call = " + param);
            Observable[] observables = new Observable[]{param};
            return observables;
        });

        list.addListener((ListChangeListener<SimpleStringProperty>) c -> {
            while (c.next()) {
                System.out.println("onChanged = " + c + "  wasupdated = " + c.wasUpdated());
            }
        });

        list.add(s1);
//        list.add(s2);

        s1.set("C");

        list.forEach(System.out::println);
    }
}
